<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 先引入 -->
    <script src="../js/axios.min.js"></script>
</head>
<body>
    
</body>
<script>
    // console.log(axios);
    // console.dir(axios);


    /* 
        axios(option)  => 返回Promise实例(默认pending), 请求有结果之后变为fulfilled, 失败则变为rejected
        
        option请求配置相关参数: 


        axios响应结构: 

    
    
    */

    // 全局默认配置
   // axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;  // 带token
    axios.defaults.baseURL = 'http://121.43.116.41/demo/php';
    axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
    
    /* axios({
        method:"get",
        url:"/searchGradeOrderLimit.php",
        baseURL:"http://121.43.116.41/demo/php",
        // headers:{},
        params:{
            wd:"",
            col:"id",
            type:"asc",
            page:1,
            size:10,
        },
    }).then(responseOption=>{
        // console.log("responseOption",responseOption);
        // console.log("data",responseOption.data);
        return responseOption.data; // responseOption.status == 200
    }).then(data=>{
        console.log("响应数据",data);
    }) */


    // axios.get(url,option);

    /* axios.get("/searchGradeOrderLimit.php",{
        // headers:{},
        baseURL:"http://121.43.116.41/demo/php",
        params:{
            wd:"",
            col:"id",
            type:"asc",
            page:1,
            size:10,
        },
    }).then(responseOption=>{
        // console.log("responseOption",responseOption);
        // console.log("data",responseOption.data);
        return responseOption.data; // responseOption.status == 200
    }).then(data=>{
        console.log("响应数据",data);
    }) */

    // axios.post(url, data[, option]])
    

    axios.post("/login.php",{user:"a123123",pwd:123123},{
        headers:{
            // "content-type":"application/json",  // 默认  
            "content-type":"application/x-www-form-urlencoded", // FormData 
        },
        baseURL:"http://121.43.116.41/demo/php",
        data:{
            user:"a123123",
            pwd:123123,
        },
    }).then(responseOption=>{
        return responseOption.data; // responseOption.status == 200
    }).then(data=>{
        console.log("响应数据",data);
    })


</script>
</html>